// JavaScript Document

var FormTest = function(){
//提交第一步
	this.error1 = false;	
	this.error2 = false;	
	this.error3 = false;	
	this.error4 = false;	
	
	$('maxid').onblur = function(){
		var nodevalue = $('minid').value;
		var tipsob = $('zbelongtips');
		tipsob.className='tips';
		FromAddSitecheck.error1 = false;
		if(nodevalue == '6700B0700B101407208A' || !nodevalue){
			tipsob.innerHTML = "请选择站点类型";
		}else{
			tipsob.className='';
			tipsob.innerHTML = "";
			FromAddSitecheck.error1 = true;
		}
	}
	$('minid').onblur = function(){
		var nodevalue = this.value;
		var tipsob = $('zbelongtips');
		tipsob.className='tips';
		FromAddSitecheck.error1 = false;
		if(nodevalue == '6700B0700B101407208A' || !nodevalue){
			tipsob.innerHTML = "请选择站点类型";
		}else{
			tipsob.className='';
			tipsob.innerHTML = "";
			FromAddSitecheck.error1 = true;
		}
	}
	$('zsitename').onblur = function(){
		var nodevalue = this.value;
		var tipsob = $('sitenametips');
		tipsob.className='tips';
		FromAddSitecheck.error2 = false;
		if( nodevalue.length < 3 ){
			tipsob.innerHTML = "站名字节在3-30";
		}else{
			tipsob.innerHTML = "正确";
			FromAddSitecheck.error2 = true;
		}
	}
	$('siteurl').onblur = function(){
		var re = new RegExp(RegExp_URL); 
		var nodevalue = this.value;
		var tipsob = $('siteurltips');
		tipsob.className='tips';
		FromAddSitecheck.error3 = false;	
		if( nodevalue.length < 1 ){
			tipsob.innerHTML = "域名不能为空";
		}else{
			if(nodevalue.match(re) == null){
				tipsob.innerHTML = "域名格式不正确";
			}else{
				tipsob.innerHTML="正确";
				FromAddSitecheck.error3 = true;	
			}
		}
	}
	$('siteinfo').onblur = function(){
		var nodevalue = this.value;
		var tipsob = $('siteinfotips');
		tipsob.className='tips';
		FromAddSitecheck.error4 = false;
		if( nodevalue.length < 200 ){
			tipsob.innerHTML = "网站简介不能少于200";
		}else if( nodevalue.length > 6000 ){
			tipsob.innerHTML = "网站简介不能少于200";
		}else{
			tipsob.innerHTML = "正确";
			FromAddSitecheck.error4 = true;
		}
	}
}
	//处理返回信息的函数
FormTest.prototype.processrequest = function(){
	var data='';
	if(request.readyState==4){//判断对象状态
		if(request.status==200){//信息已成功返回，开始处理信息
			var results = request.responseText;
			/*
			var results = request.responseXML;
			//var results = request.responseText;
			var xmldata = results.getElementsByTagName("data");
 			for (var i = 0; i< xmldata.length; i++){
				data =  xmldata[i];
				name = data.getElementsByTagName("mesg")[0].firstChild.nodeValue;
			}
			*/
			if(results == 1){
				reobj.innerHTML = '用户名已经存在';
			}else if(results == 2){
				reobj.innerHTML = '恭喜您可以注册这个用户';
				Fromcheck.error1 = true;
			}else if(results == 3){
				reobj.innerHTML = '用户名不能为空';
			}else{
				reobj.innerHTML = '用户名书写不正确';
			}
		}else{//页面不正常
			//alert("您所请求的页面不正常！");
		}
	}
}

FormTest.prototype.AllSubmit = function(){
	if(!this.error1){
		$('minid').focus();
		return false;
	}
	if(!this.error2){
		$('zsitename').focus();
		return false;
	}
	if(!this.error3){
		$('siteurl').focus();
		return false;
	}
	if(!this.error4){
		$('siteinfo').focus();
		return false;
	}
	var flag = this.error1 && this.error2 && this.error3 && this.error4;
	if(flag){
		$('submit').disabled = true;
	}
	return flag;
}

window.onload=function(){
	FromAddSitecheck = new FormTest();
} 














